package com.iversonx.decorator.example_1.service.v2.config;

import com.iversonx.decorator.example_1.service.v2.PrizeCalculator;
import com.iversonx.decorator.example_1.service.v2.calculator.DefaultPrizeCalculator;
import com.iversonx.decorator.example_1.service.v2.calculator.GroupPrizeCalculator;
import com.iversonx.decorator.example_1.service.v2.calculator.MonthPrizeCalculator;
import com.iversonx.decorator.example_1.service.v2.calculator.SumPrizeCalculator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PrizeCalculatorConfig {

    /**
     * 配置奖金计算方式
     */
    @Bean
    public PrizeCalculator prizeCalculator() {
        PrizeCalculator defaultPrizeCalculator = new DefaultPrizeCalculator();
        // 当月业务奖
        PrizeCalculator monthPrizeCalculator = new MonthPrizeCalculator(defaultPrizeCalculator);
        // 个人累计奖
        PrizeCalculator sumPrizeCalculator = new SumPrizeCalculator(monthPrizeCalculator);
        // 当月团队奖
        return new GroupPrizeCalculator(sumPrizeCalculator);
    }
}
